import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { fileURLToPath } from 'url';
import path from 'path';

const filename = fileURLToPath(import.meta.url);
const pathSegments = path.dirname(filename);

export default defineConfig({
    plugins: [vue()],
    base: "./",
    resolve: {
        alias: {
            '@': path.resolve(pathSegments, './src'),
        },
        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
    },
    define: {
        'process.env': {},
        'process.platform': null,
        'process.version': null
    },
    build: {
        outDir: "../wwwroot",
        emptyOutDir: true,
        sourcemap: true, // Enable source maps for production debugging
        rollupOptions: {
            output: {
                sourcemapExcludeSources: false
            }
        }
    },
    server: {
        host: '127.0.0.1',
        port: 5173,
        strictPort: true,
        cors: true
    },
    worker: {
        format: 'es'
    },
    css: {
        preprocessorOptions: {
            sass: {
                api: 'modern'
            },
            scss: {
                api: 'modern'
            }
        },
        devSourcemap: true // Enable CSS source maps in development
    }
})